<?php

/**
 * This is the model class for table "{{r_detalle_entidad}}".
 *
 * The followings are the available columns in table '{{r_detalle_entidad}}':
 * @property integer $grid_detalle_entidad_id
 * @property integer $grid_persona_id
 * @property integer $grid_entidad_id
 * @property string $campo_1
 * @property string $campo_2
 * @property string $campo_3
 * @property string $campo_4
 * @property string $campo_5
 *
 * The followings are the available model relations:
 * @property Mydb.rEntidad $gridEntidad
 * @property Persona $gridPersona
 */
class RDetalleEntidad extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return RDetalleEntidad the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{r_detalle_entidad}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array(' grid_persona_id, grid_entidad_id', 'required'),
			array(' grid_persona_id, grid_entidad_id', 'numerical', 'integerOnly'=>true),
			array('campo_1, campo_2, campo_3, campo_4, campo_5', 'length', 'max'=>45),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('grid_detalle_entidad_id, grid_persona_id, grid_entidad_id, campo_1, campo_2, campo_3, campo_4, campo_5', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'gridEntidad' => array(self::BELONGS_TO, 'rEntidad', 'grid_entidad_id'),
			'gridPersona' => array(self::BELONGS_TO, 'Persona', 'grid_persona_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'grid_detalle_entidad_id' => 'Grid Detalle Entidad',
			'grid_persona_id' => 'Grid Persona',
			'grid_entidad_id' => 'Grid Entidad',
			'campo_1' => 'Campo 1',
			'campo_2' => 'Campo 2',
			'campo_3' => 'Campo 3',
			'campo_4' => 'Campo 4',
			'campo_5' => 'Campo 5',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('grid_detalle_entidad_id',$this->grid_detalle_entidad_id);
		$criteria->compare('grid_persona_id',$this->grid_persona_id);
		$criteria->compare('grid_entidad_id',$this->grid_entidad_id);
		$criteria->compare('campo_1',$this->campo_1,true);
		$criteria->compare('campo_2',$this->campo_2,true);
		$criteria->compare('campo_3',$this->campo_3,true);
		$criteria->compare('campo_4',$this->campo_4,true);
		$criteria->compare('campo_5',$this->campo_5,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}